package com.bw.mvvm.network.load;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.bw.mvvm.R;


import java.io.File;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

public class LoadImage {

    public static void loadMatchImg(String url, ImageView img){
        Glide.with(img.getContext()).load(url)
                .placeholder(R.drawable.utils_toast_bg)
                .error(R.drawable.brvah_sample_footer_loading)
                .centerCrop()
                .into(img);
    }

    public static void loadCircleImg(String url, ImageView img){
        Glide.with(img.getContext())
                .load(url)
                .error(R.drawable.brvah_sample_footer_loading)
                .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                .into(img);
    }

    public static void loadCircleImg(File file, ImageView img){
        Glide.with(img.getContext())
                .load(file)
                .error(R.drawable.brvah_sample_footer_loading)
                .apply(RequestOptions.bitmapTransform(new CircleCrop()))
                .into(img);
    }
    public static void loadRoundImg(String url, ImageView img,int radius){
        Glide.with(img.getContext())
                .load(Api.baseImgUrl+url)
                // 圆角效果
                .transform(new MultiTransformation(new RoundedCornersTransformation(radius, 0)))
                .into(img);
    }
}
